<?php
/**
 * @file TwoLevelNavController.php
 * @author LinLin
 * @date 2016年9月13日 下午2:42:07
 * @brief 
 */
namespace haibao\cms\business\control\pc\common;

use haibao\frame\Environment;
use \haibao\cms\web\common\ftp;


class TwoLevelNavController extends \haibao\cms\business\control\pc\channel\ChannelController{

    public function __construct($updateTime = null,$controlId = '',$isPublish = ''){
        parent::__construct($updateTime,$controlId,$isPublish);
    }
    
    public function displayTemplateHtml(){
        $controlData = $this->getParameter(self::$CONTROL_DATA);
        $content = $this->getParameter(self::$CONTROL_CONTENT);
        $path = $this->generateHtmlPath(__CLASS__);
        
        //二级导航
        $twoNavList = array();
        $siteParentIdArr = array(
            80=>array('topTagId'=>1383,'controllerId'=>161),
            51=>array('topTagId'=>310,'controllerId'=>47),
            56=>array('topTagId'=>24,'controllerId'=>81),
            57=>array('topTagId'=>955,'controllerId'=>168),
            87=>array('topTagId'=>520,'controllerId'=>99),
            84=>array('topTagId'=>7455,'controllerId'=>82),
            89=>array('topTagId'=>211,'controllerId'=>110),
            85=>array('topTagId'=>6863,'controllerId'=>90),
            221=>array('topTagId'=>11280,'controllerId'=>312),// dev 224 pre 218 online 221
        );
        foreach($siteParentIdArr as $parentId=>$channelId){
            $twoNavList[$channelId['topTagId']] = \haibao\cms\business\control\PublicController::getLowerChannelById($parentId);
        }
        $controllerId = $parm = array();
        foreach($siteParentIdArr as $parentId=>$channelId){
            $controllerId = \haibao\cms\business\control\PublishController::getPageControlDataByControlId($channelId['controllerId']);
            foreach($controllerId as $key=>$val){
                $temp = json_decode($val->ParameterValue);
                $parm[$channelId['topTagId']][$temp->showOrder] = json_decode($val->ParameterValue);
            }
        }
        foreach($twoNavList as $parentId=>$channelId){
            if(isset($parm[$parentId])){
                foreach($parm[$parentId] as $key=>$val){
                    array_push($twoNavList[$parentId], (array)$val);
                }
            }
        }
     
        //$file= 'D:\code\php\www\trunk\sites\html\diytaghtml\twolevelnav.php';
        //$file = '/data/web/www/trunk/sites/html/diytaghtml/twolevelnav.php';
        $text = '<?php '."\n".'$twoLevelNav = '.var_export($twoNavList,true).';';
        $this->assign('text', $text);
        $isNewHtml = $this->generateHtml($path,$content);
        $content = $this->getHtml($path);
        $content = $this->replaceCDNLink($content);
        return $content;
       
    }
  
}